
import blog.dao.pojo.Article;
import blog.service.ArticleService;
import blog.vo.ArticleVo;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONUtil;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

import javax.swing.plaf.synth.SynthOptionPaneUI;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.time.LocalDateTime;
import java.util.*;

public class test {

    @Autowired
    private ArticleService articleService;

    @Test
    public void test() {

        String s = SecureUtil.md5("123456vs3dv$$#%");
        System.out.println(s);
    }

    @Test
    public void test2() {
        DateTime dateTime = new DateTime();

//        System.out.println(System.currentTimeMillis());

        DateTime date = DateUtil.date();
        String str = DateUtil.format(date, "yyyy-MM-dd HH:mm:ss");
        System.out.println(str);

        DateTime parse = DateUtil.parse(str);
        long time = parse.getTime();
        System.out.println(time);

    }

    @Test
    public void test3() {

        Article article = new Article();
        article.setCreateDate(DateUtil.date().getTime());
        article.setTitle("hutool的慰问");

        ArticleVo vo = new ArticleVo();

//        System.out.println(vo);

        BeanUtil.copyProperties(article, vo);

//        System.out.println(vo);

        String s = JSONUtil.toJsonStr(vo);
//        System.out.println(s1);


        Article article1 = JSONUtil.toBean(s, Article.class);
        System.out.println(article1);

    }

    @Test
    public void test4() throws IOException {
        byte[] b = new byte[28];
        FileInputStream inputStream = new FileInputStream("C:\\Users\\hp\\Desktop\\child.jpg");
        inputStream.read(b, 0, 28);
        inputStream.close();

        System.out.println(b);
        System.out.println(Arrays.toString(b));

    }


    @Test
    public void test5() {
    }
}
